from django.db import models
from myapp.models import *
from datetime import datetime
# Create your models here.
# 菜单表
class MenuModel(models.Model):
    menu_name = models.CharField('菜单名称',max_length=20,default='')
    menu_way = models.CharField('菜单路径',max_length=30,default='')
    menu_logo = models.CharField('菜单图标',max_length=50,default='')
    menu_level = models.ForeignKey('self',related_name='subs',on_delete=models.CASCADE,null=True,blank=True)
    menu_sort = models.CharField('排序',max_length=3,default='')

    def __str__(self):
        return self.menu_name

    class Meta:
        db_table = 'menu_tb'
        verbose_name_plural = '菜单表'

# 登录日志表
class LoginLogModel(models.Model):
    user_id = models.ForeignKey(to=UserModel,on_delete=models.CASCADE,verbose_name='登录用户id')
    login_equip = models.CharField('登陆设备',max_length=20,default='')
    login_time = models.CharField('登录时间',max_length=200,default=datetime.now)
    login_ip = models.CharField('登录IP',max_length=30,default='')

    def __str__(self):
        return self.login_equip

    class Meta:
        db_table = 'login_log_tb'
        verbose_name_plural = '登陆日志'

# 操作日志表
class ActLogModel(models.Model):
    actor_id = models.ForeignKey(to=UserModel,on_delete=models.CASCADE,verbose_name='操作人id外键')
    act_thing = models.CharField('操作行为',max_length=200,default='')
    act_time = models.CharField('操作时间',max_length=300,default=datetime.now)

    def __str__(self):
        return self.actor_id

    class Meta:
        db_table = 'act_log_tb'
        verbose_name_plural = '操作日志表'

# 工资条表
class SalaryModel(models.Model):
    name = models.CharField('姓名',max_length=100,default='')
    atten = models.CharField('出勤',max_length=10,default='')
    absent = models.CharField('旷工',max_length=10,default='')
    base_pay = models.CharField('基本工资',max_length=20,default='')
    post_pay = models.CharField('岗位工资',max_length=20,default='')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'salary_tb'
        verbose_name_plural = '工资条表'

# 材料表
class StuffModel(models.Model):
    stuff = models.CharField('材料名称',max_length=30,default='')
    stuff_addr = models.CharField('材料地址',max_length=200,default='')
    upper = models.ForeignKey(to=UserModel,on_delete=models.CASCADE,verbose_name='上传人')
    up_time = models.CharField('上传时间',max_length=200,default=datetime.now)

    def __str__(self):
        return self.stuff

    class Meta:
        db_table = 'stuff_tb'
        verbose_name_plural = '材料表'


#邮箱表
class EmailModel(models.Model):
    employee = models.ForeignKey(to=UserModel, on_delete=models.CASCADE, verbose_name="所属员工")
    email_receipt = models.CharField(max_length=56,verbose_name='收件人邮箱')
    email_data = models.CharField(max_length=56,verbose_name='邮箱内容')
    title = models.CharField(max_length=56,verbose_name='标题')
    url = models.CharField(max_length=56,verbose_name='地址')
    def __str__(self):
        return self.title
    class Meta:
        db_table = 'email_model'
        verbose_name_plural = "邮箱表"


#抄送人表
class CopyModel(models.Model):
    email = models.ForeignKey(to=EmailModel,on_delete=models.CASCADE,verbose_name='所属邮箱')
    email_copy = models.CharField(max_length=56,verbose_name='抄送人邮箱')
    def __str__(self):
        return self.email_copy
    class Meta:
        db_table = 'copy_model'
        verbose_name_plural = "抄送人表"

